const VueAxios = {
  install (Vue, instance) {
    if (this.isInstalled) {
      return
    }

    if (!instance) {
      throw new Error('You have to install axios first')
    }

    this.isInstalled = true

    Object.defineProperties(Vue.prototype, {
      axios: {
        get () {
          return instance
        }
      },
      $http: {
        get () {
          return instance
        }
      }
    })
  }
}

export default VueAxios
